package com.production.CoursePlatform.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.production.CoursePlatform.entity.Teaching;
import org.apache.ibatis.annotations.Mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.Param;

import java.util.List;

@Mapper
public interface TeachingMapper extends BaseMapper<Teaching> {

    // 查找特定 tID 的所有记录
    @Select("SELECT * FROM teaching WHERE t_id = #{tID}")
    List<Teaching> findByTID(@Param("tID") String tID);

    // 插入新的 Teaching 记录，不设置 c_id
    @Insert("INSERT INTO teaching (ct_id, c_number, t_id) VALUES (#{ctID}, #{cNumber}, #{tID})")
    int insertWithoutCID(Teaching teaching);

    // 更新 Teaching 记录
    @Update("UPDATE teaching SET ct_id = #{ctID}, c_number = #{cNumber} WHERE c_id = #{cID}")
    int updateTeaching(Teaching teaching);

    // 删除 Teaching 记录
    @Delete("DELETE FROM teaching WHERE c_id = #{cID}")
    int deleteByCID(@Param("cID") int cID);
}

